package com.jacky.iot.handler;

import com.jacky.iot.config.MqttServerConfig;
import com.jacky.iot.handler.impl.Mqtt3Handler;
import com.jacky.iot.handler.impl.Mqtt5Handler;
import com.jacky.iot.manager.EndpointManager;

public class MqttHandlerFactory {

    public static MqttHandler createHandler(String protocolVersion,
                                            EndpointManager endpointManager,
                                            MqttServerConfig config) {
        return switch (protocolVersion) {
            case "MQTT_3" -> new Mqtt3Handler(endpointManager, config);
            case "MQTT_5" -> new Mqtt5Handler(endpointManager, config);
            default -> throw new IllegalArgumentException("Unsupported protocol: " + protocolVersion);
        };
    }
}
